package com.dxb.test.spring_async;

/**
 * 线程本地数据上下文
 *
 * @author DLS
 * @date 2023/02/03
 */
public class ThreadLocalDataContext {

    private static ThreadLocal<String> DATA = new ThreadLocal<>();

    public static void set(String data) {
        DATA.set(data);
        System.out.println(Thread.currentThread().getName() + ":set:" + data);
    }

    public static String get() {
        String data = DATA.get();
        System.out.println(Thread.currentThread().getName() + ":get:" + data);
        return data;
    }

    public static void remove() {
        System.out.println(Thread.currentThread().getName() + ":remove:");
        DATA.remove();
    }
}
